package top.lilele.adminSystem.web;

import cn.dev33.satoken.stp.StpUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lilele.adminSystem.dao.MeetMinutesDao;
import top.lilele.adminSystem.dto.IdParams;
import top.lilele.adminSystem.service.AdminMeetMinutesService;
import top.lilele.adminSystem.utils.BaseResponse;
import top.lilele.adminSystem.utils.ResponseCodeEnum;
import top.lilele.adminSystem.vo.MeetMinutesVo;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lilele
 */
@RestController
@RequestMapping(value = "meetMinutes")
public class AdminMeetMinutesController {
    @Resource
    AdminMeetMinutesService adminMeetMinutesService;

    @PostMapping(value = "add")
    public BaseResponse add(@Validated @RequestBody MeetMinutesDao meetMinutesDao) {
        meetMinutesDao.setCreatedId(StpUtil.getLoginIdAsString());
        adminMeetMinutesService.add(meetMinutesDao);
        return BaseResponse.info(ResponseCodeEnum.Success, null);
    }

    @PostMapping(value = "queryMeetMinutesList")
    public BaseResponse queryMeetMinutesList(@Validated @RequestBody IdParams idParams) {
        List<MeetMinutesVo> list = adminMeetMinutesService.queryMeetMinutesList(idParams.getId());
        return BaseResponse.info(ResponseCodeEnum.Success, list);
    }

    @PostMapping(value = "updateMeetMinutesById")
    public BaseResponse updateMeetMinutesById(@Validated @RequestBody MeetMinutesDao meetMinutesDao) {
        adminMeetMinutesService.updateMeetMinutesById(meetMinutesDao);
        return BaseResponse.info(ResponseCodeEnum.Success, null);
    }

    @PostMapping(value = "deleteMeetMinutesById")
    public BaseResponse deleteMeetMinutesById(@Validated @RequestBody IdParams idParams) {
        adminMeetMinutesService.deleteMeetMinutesById(idParams.getId());
        return BaseResponse.info(ResponseCodeEnum.Success, null);
    }
}
